package org.xdq.demo.emp.dto;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class EmpDto {

    private String e_id;
    private String e_name;
    private Double e_sal;
    private Date e_date;

    private Double e_sal_start;
    private Double e_sal_end;

    private Date e_date_start;
    private Date e_date_end;

    public Double getE_sal_start() {
        return e_sal_start;
    }

    public void setE_sal_start(Double e_sal_start) {
        this.e_sal_start = e_sal_start;
    }

    public Double getE_sal_end() {
        return e_sal_end;
    }

    public void setE_sal_end(Double e_sal_end) {
        this.e_sal_end = e_sal_end;
    }

    //定义时间格式，以备控制器可以正确识别
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public Date getE_date_start() {
        return e_date_start;
    }

    public void setE_date_start(Date e_date_start) {
        this.e_date_start = e_date_start;
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public Date getE_date_end() {
        return e_date_end;
    }

    public void setE_date_end(Date e_date_end) {
        this.e_date_end = e_date_end;
    }

    public String getE_id() {
        return e_id;
    }

    public void setE_id(String e_id) {
        this.e_id = e_id;
    }

    public String getE_name() {
        return e_name;
    }

    public void setE_name(String e_name) {
        this.e_name = e_name;
    }

    public Double getE_sal() {
        return e_sal;
    }

    public void setE_sal(Double e_sal) {
        this.e_sal = e_sal;
    }

    public Date getE_date() {
        return e_date;
    }

    public void setE_date(Date e_date) {
        this.e_date = e_date;
    }


    @Override
    public String toString() {
        try {
            ObjectMapper objectMapper = new ObjectMapper();//转换json的工具类
            return objectMapper.writeValueAsString(this);//将一个JavaBean对象转换为json串
        } catch (JsonProcessingException e) {
            return "EmpDto{" +
                "e_id='" + e_id + '\'' +
                ", e_name='" + e_name + '\'' +
                ", e_sal=" + e_sal +
                ", e_date=" + e_date +
                ", e_sal_start=" + e_sal_start +
                ", e_sal_end=" + e_sal_end +
                ", e_date_start=" + e_date_start +
                ", e_date_end=" + e_date_end +
                '}';
        }
    }
}
